package ExamSystemClient.client;

import ExamSystemClient.managerSystem.ExamManagement.*;
import ExamSystemClient.managerSystem.studentManagement.*;
import ExamSystemClient.model.ChoiceQuestion;
import ExamSystemClient.model.Student;

import java.util.List;

/**
 * 管理员系统
 *
 * @author Shuxian Huang
 */
public class ManagerSystem {
    /**
     * 题库
     */
    private List<ChoiceQuestion> questions;

    /**
     * 学生信息
     */
    private List<Student> students;

    public ManagerSystem(List<ChoiceQuestion> questions, List<Student> students) {
        this.questions = questions;
        this.students = students;
    }

    /**
     * 管理员执行操作
     */
    public void managerOperate(){
        while(true){
            //1、管理员操作界面绘制
            System.out.println("  \n\n\t\t    管理员系统");
            System.out.println("---------------------------------");
            System.out.print("  [1]学员管理模块");
            System.out.println("  [2]考题管理模块");
            System.out.println("  [0]退出系统");
            System.out.println("---------------------------------");
            System.out.println("请选择要进行的业务编号：");

            int choose = ClientScanner.getScanner().nextInt();
            switch (choose) {
                case 1:
                    System.out.println("正在进入学员管理模块");
                    studentManage();
                    break;
                case 2:
                    System.out.println("正在进入考题管理模块");
                    examManage();
                    break;
                case 0:
                    System.out.println("正在退出管理员系统。。。");
                    return;
                default:
                    System.out.println("输入错误，请重新选择！");
            }
        }
    }

    private void studentManage(){
        while(true) {
            System.out.println("  \n\n\t\t   学员管理模块");
            System.out.println("---------------------------------");
            System.out.print("  [1]增加学员信息");
            System.out.println("  [2]删除学员信息");
            System.out.print("  [3]修改学员信息");
            System.out.println("  [4]查询学员信息");
            System.out.print("  [5]遍历学员信息");
            System.out.println("  [0]退出模块");
            System.out.println("---------------------------------");
            System.out.println("请选择要进行的业务编号：");
            int choose = ClientScanner.getScanner().nextInt();
            switch (choose) {
                case 1:
                    new AddStudent(students).show().operate();
                    break;
                case 2:
                   new DeleteStudent(students).show().operate();
                    break;
                case 3:
                    new ModifyStudent(students).show().operate();
                    break;
                case 4:
                    new SearchStudent(students).show().operate();
                    break;
                case 5:
                    new PrintStudents(students).show().operate();
                    break;
                case 0:
                    System.out.println("正在退出学员管理模块。。。");
                    return;
                default:
                    System.out.println("输入错误，请重新选择！");
            }
        }
    }

    private void examManage(){
        while(true) {
            System.out.println("  \n\n\t\t  考题管理模块");
            System.out.println("---------------------------------");
            System.out.print("  [1]增加考题");
            System.out.println("  [2]删除考题");
            System.out.print("  [3]修改考题");
            System.out.println("  [4]查询考题");
            System.out.print("  [5]导入考题");
            System.out.println("  [6]遍历考题");
            System.out.println("  [0]退出模块");
            System.out.println("---------------------------------");
            System.out.println("请选择要进行的业务编号：");
            int choose = ClientScanner.getScanner().nextInt();
            switch (choose) {
                case 1:
                    new AddQuestion(questions).show().operate();
                    break;
                case 2:
                    new DeleteQuestion(questions).show().operate();
                    break;
                case 3:
                    new ModifyQuestion(questions).show().operate();
                    break;
                case 4:
                    new SearchQuestion(questions).show().operate();
                    break;
                case 5:
                    new ImportQuestions(questions).show().operate();
                    break;
                case 6:
                    new PrintQuesionts(questions).show().operate();
                    break;
                case 0:
                    System.out.println("正在退出考题管理模块。。。");
                    return;
                default:
                    System.out.println("输入错误，请重新选择！");
            }
        }
    }

    public List<ChoiceQuestion> getQuestions() {
        return questions;
    }

    public List<Student> getStudents() {
        return students;
    }
}
